
<style>
    #report_result_table td, #report_result_table th {
        font-size: 10pt;
    }
</style>

<h3 class="text-center"><?php echo $report['title']; ?></h3>
<p class="text-center"><?php echo $report['description']; ?></p>

<table id="report_result_table" class="table table-condensed table-bordered">
    <thead>
        <?php
        echo "<td style='text-align: right;'>&nbsp;</td>";
        
        foreach($report['ReportColumn'] as $column) {
            echo "<th>{$column['ReportColumnOption']['display_name']}</th>";
        }
        ?>
    </thead>
    
    <tbody>
        <?php 
        $count = 1;
        foreach($rows['Results'] as $row) {
            echo "<tr>";
            echo "<td style='text-align: right;'>$count.</td>";
            
            foreach($report['ReportColumn'] as $column) {  
                $field_name = $column['ReportColumnOption']['field_name'];
                $parts = explode(".", $field_name);
                $value = "";
                
                if( count($parts) > 1 ) {
                    if( isset($row[$parts[0]][$parts[1]]) ){
                        $value = $row[$parts[0]][$parts[1]];
                    }
                    
                    else if( isset($row[0][$parts[1]]) ) {
                        $value = $row[0][$parts[1]];
                    }
                    
                    else {
                        $value = '';
                    }
                }
                
                echo "<td>$value</td>";
            }
            
            echo "</tr>";
            
            $count++;
        }
        ?>
    </tbody>
</table>